var express = require('express');
var   router   = express.Router();
const dataCtrl = require('../controllers/user.controller');

function verifyToken(req,res,next){
  const bearerHeader = req.headers['authorization'];
  if(typeof bearerHeader !== 'undefined'){
      const bearer      = bearerHeader.split(' ');
      const bearerToken = bearer[1];
            req.token   = bearerToken;
      next();
  }else{
      res.sendStatus(403)
  }
}

/* GET users listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});

//rest api get/post/put/delete
router.post('/data', dataCtrl.create);
router.get('/data/:id', dataCtrl.getdata);
router.put('/data/:id', dataCtrl.update);
router.delete('/data/:id', dataCtrl.remove);
router.post('/list',dataCtrl.list);
router.post('/login', dataCtrl.login);
router.post('/cateusers_0', dataCtrl.cateusers_0);
router.post('/cateusers_1', dataCtrl.cateusers_1);
router.post('/data/removes', dataCtrl.removes);

module.exports = router;
